package suzf.top.kotlinjava.test.user

import com.baomidou.mybatisplus.extension.plugins.pagination.Page
import org.junit.Test
import suzf.top.kotlinjava.common.entity.User
import suzf.top.kotlinjava.common.mapper.UserMapper
import suzf.top.kotlinjava.test.ApplicationTests
import suzf.top.kotlinjava.service.service.UserService
import javax.annotation.Resource

/**
 *  用户相关测试类
 *========================
 * Created with IntelliJ IDEA
 * Author:Mr.Su
 * Blog: https://suzf.top/
 * Date:2019/10/12
 * ========================
 */
class UserTest : ApplicationTests() {

    @Resource
    lateinit var userService: UserService

    @Resource
    lateinit var userMapper: UserMapper


    /**
     *  查询全部并分页，输出每条用户信息
     */
    @Test
    fun selectAllAndPage() {
        val page = Page<User>(1, 10)
        val userIPage = userMapper.selectPage(page,null)
        println("总条数 ------> " + userIPage.total)
        println("当前页数 ------> " + userIPage.current);
        println("总页数 ------> " + userIPage.pages);
        println("当前每页显示数 ------> " + userIPage.size);
        userIPage.records.forEachIndexed { index, user ->
            println("${index}用户名：----------> ${user.username}")
            println("${index}密码：----------> ${user.password}")
            println("${index}状态：----------> ${user.ban}")
            println("${index}角色：----------> ${user.role}")
            println("${index}权限：----------> ${user.permission}")
        }
    }


}
